home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / news / inn1.000 / inn1.4sec-linux-src.tar / inn / lib / closeonexec.c < prev    next >
C/C++ Source or Header  |  1994-09-20  |  866b  |  55 lines

  1. /*  $Revision: 1.5 $
  2. **
  3. */
  4. #include "configdata.h"
  5. #include <stdio.h>
  6. #include <sys/types.h>
  7. #include <errno.h>
  8. #include "clibrary.h"
  9.  
  10.  
  11.  
  12. #if    defined(CLX_IOCTL)
  13. #include <bsd/sgtty.h>
  14.  
  15.  
  16. /*
  17. **  Mark a file close-on-exec so that it doesn't get shared with our
  18. **  children.  Ignore any error codes.
  19. */
  20. void
  21. CloseOnExec(fd, flag)
  22.     int        fd;
  23.     int        flag;
  24. {
  25.     int        oerrno;
  26.  
  27.     oerrno = errno;
  28.     (void)ioctl(fd, flag ? FIOCLEX : FIONCLEX, (char *)NULL);
  29.     errno = oerrno;
  30. }
  31. #endif    /* defined(CLX_IOCTL) */
  32.  
  33.  
  34.  
  35. #if    defined(CLX_FCNTL)
  36. #include <fcntl.h>
  37.  
  38.  
  39. /*
  40. **  Mark a file close-on-exec so that it doesn't get shared with our
  41. **  children.  Ignore any error codes.
  42. */
  43. void
  44. CloseOnExec(fd, flag)
  45.     int        fd;
  46.     int        flag;
  47. {
  48.     int        oerrno;
  49.  
  50.     oerrno = errno;
  51.     (void)fcntl(fd, F_SETFD, flag ? 1 : 0);
  52.     errno = oerrno;
  53. }
  54. #endif    /* defined(CLX_FCNTL) */
  55.